package validator;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import exceptions.InvalidPhoneNumberException;

/**
 * Implements a validator of phone numbers
 * @author Alexandre, Cristovao, Raul, Rodolpho, Tales
 * @version 1.1
 * @milestone Number 2
 */
public class PhoneValidator {
	
	/**
	 * Validates a phone number
	 * @param phoneNumber
	 * @throws InvalidPhoneNumberException
	 */
	public static void validatePhoneNumber(String phoneNumber) throws InvalidPhoneNumberException{
		String expression = "^[\\d]{12}$";
		CharSequence inputStr = phoneNumber;
		Pattern pattern = Pattern.compile(expression);
		Matcher matcher = pattern.matcher(inputStr);
		if (!matcher.matches())
			throw new InvalidPhoneNumberException("Numero de telefone invalido");
	}

}
